﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OnlineMovieTicket.Data.IRepository;
using OnlineMovieTicket.Data.Repository;

namespace OnlineMovieTicket.Services.Services
{
    public class TransactionService :  IServices.ITransactionService
    {
        ITransactionRepository transactionRepository;

        public TransactionService()
        { transactionRepository = new TransactionRepository(); }



        public List<Model.TransactionDetail> getMovieBookingDetail(int movieTimeTableId)
        {
            transactionRepository.resetPendingBooking();
            return transactionRepository.getMovieBookingDetail(movieTimeTableId);
        }

        public void resetPendingBooking()
        {
            transactionRepository.resetPendingBooking();
        }

        public void bookMovieTicket(Model.TransactionDetail transactionDetail)
        {
            transactionRepository.bookMovieTicket(transactionDetail);
        }

        public void updateTransactionTime(int transactionID)
        {
            transactionRepository.updateTransactionTime(transactionID);
        }

        public List<Model.TransactionDetail> getCinemasMovieDetail(Model.TransactionDetail movieDetail)
        {
            return transactionRepository.getCinemasMovieDetail(movieDetail);
        }

        public List<Model.TransactionDetail> getUserTransactionDetail(Model.Customer customerDetail)
        {
            return transactionRepository.getUserTransactionDetail(customerDetail);
        }

        public List<Model.TransactionDetail> getCheckBookingByNric(String nric)
        {
            return transactionRepository.getCheckBookingByNric(nric);
        }

        public List<Model.TransactionDetail> getCheckBookingByVerificationID(int verificationID)
        {
            return transactionRepository.getCheckBookingByVerificationID(verificationID);
        }

        public int getTransactionNum()
        {
            return transactionRepository.getMaxTransactionNum();
        }

        public Model.TransactionDetail saveTransaction(int transactionId, String seatNum, String status, int movieAssignId)

        {
            String uniqueId=Guid.NewGuid().ToString();

            Model.TransactionDetail transModel = transactionRepository.saveTransaction(transactionId, seatNum, status, uniqueId, movieAssignId);

            return transModel;
        
        }

        public Model.TransactionDetail getMovieDetail(int movieAssignmentID)
        {
            return transactionRepository.getMovieDetail(movieAssignmentID);
        }

        public Model.TransactionDetail getTransactionDetail(int transactionID)
        {
            return transactionRepository.getTransactionDetail(transactionID);
        }

        public Model.TransactionDetail saveTransaction(int movieAssignId)
        {
            return transactionRepository.saveTransaction(movieAssignId);
        }


    }
}
